<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>商品基本信息添加</title>

<script type="text/javascript">
var trIndex = 0;
function addNewFile(){
	var imgTbody = document.getElementById("imgTbody");
	var newTr = document.createElement("tr");
	var trid =  "imgtr"+(trIndex++);
	newTr.id =trid;
	
	var td1 = document.createElement("td");
	td1.innerText = '小图片';
	
	var td2 = document.createElement("td");
	var newFileinput  = document.createElement("input");
	newFileinput.type="file";
	newFileinput.name="goodsImg";
	td2.appendChild(newFileinput);
	
	var td3 = document.createElement("td");
	var newDeleBut  = document.createElement("input");
	newDeleBut.type="button";
	newDeleBut.value="删除";
	td3.appendChild(newDeleBut);
	newDeleBut.onclick=function(){
		var imgTbody = document.getElementById("imgTbody");
		var deleteTr = document.getElementById(trid);
		imgTbody.removeChild(deleteTr);
	}
	newTr.appendChild(td1);
	newTr.appendChild(td2);
	newTr.appendChild(td3);
	
	imgTbody.appendChild(newTr);
}
</script>
</head>
<body>
<form action="<%=request.getContextPath() %>/file/addGoods.do" method="post" enctype="multipart/form-data" target="mainFrame">
		<table>
			<thead>
				<tr>
					<td>商品名称</td>
					<td><input type="text" name="name" /></td>
				</tr>
				<tr>
					<td>价格</td>
					<td><input type="text" name="price"/></td>
				</tr>
				<tr>
					<td>折扣</td>
					<td><input type="text" name="discount"/></td>
				</tr>
				<tr>
					<td>品牌</td>
					<td><input type="text" name="brand" /></td>
				</tr>
				<tr>	
					<td>颜色</td>
					<td><input type="text" name="color" ></td>
				</tr>
				<tr>
					<td>型号</td>
					<td><input type="text" name="model"/></td>
				</tr>
				<tr>
					<td>数量</td>
					<td><input type="text" name="number"/></td>
				</tr>
				<tr>
					<td>类别</td>
					<td>
					<input type="text" name="type" value="${goodsTypeId}" />
						<!-- <select name="type" id="type" onchange="changeType()">
							<option value="2">电视</option>
							<option value="3">冰箱</option>
							<option value="4">洗衣机</option>
							<option value="6">笔记本电脑</option>
							<option value="7">台式机</option>
						</select> -->
					</td>
				</tr>
			</thead>
			<tbody id="imgTbody">
				<tr>
					<td>
						大图片
					</td>
					<td>
						<input type="file" name="goodsImg" />
					</td>
					<td>	
						<input type="button" value="添加" onclick="addNewFile()">
					</td>
				</tr>
				</tbody>
				<c:forEach items="${attrList}" var="attr">
				<tr>
					<td colspan="4">
						<c:out value="${attr}" escapeXml="false"></c:out>
					</td>
				</tr>
				</c:forEach>
				
			
			<tr>
				<td>
					<input type="submit" value="提交"/>
				</td>
				<td>
					<input type="reset" value="重置"/>
				</td>
			</tr>
		</table>
	</form>
</body>
</html>